﻿#region Copyright (c) 2010 R. Uittenbosch
/*
* Copyright (C) 2010 R. Uittenbosch
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 
* associated documentation files (the "Software"), to deal in the Software without restriction, including 
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the 
* following conditions:
* 
* The above copyright notice and this permission notice shall be included in all copies or substantial 
* portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO 
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using TouchUI.System.Mobile.Mvc;

namespace LinkedIn.Mobile
{
  public class HeaderListItem : ScrollListItem
  {
    private string _header;
    #region Protected variables

    // Some defaults
    public    static int ItemHeight = 15 * Common.Instance.ScreenFactor;
    protected static int Spacing = 2 * Common.Instance.ScreenFactor;
    protected static int HSpacing = 10 * Common.Instance.ScreenFactor;
    #endregion


    public HeaderListItem(string header)
    {
      _header = header;
      Name = _header;
    }

    public override void Paint(Graphics g)
    {
      // Where should we draw
      RectangleF drawRec = new RectangleF(Rectangle.Left + HSpacing,
                                              Rectangle.Top + 8 ,
                                              Rectangle.Width - (16 * ScreenFactor),
                                              ItemHeight);
      // Fill the background
      g.FillGradientV(new Rectangle(Rectangle.Left + 1,
                                    Rectangle.Top + 1,
                                    Rectangle.Width - 2,
                                    Rectangle.Height - 2),
                                    Color.Black, Color.FromArgb(0, 102, 153));

      Font headerFont = new Font(Common.Instance.SmallBoldFont.Name, 6F, FontStyle.Bold);

      // Measure the place needed to draw the string
      Size size = g.MeasureString(_header, Common.Instance.SmallBoldFont, drawRec);
      g.DrawString(_header,
                              headerFont,
                              Common.Instance.HighTextBrush,
                              drawRec,
                              new StringFormat());
      Height = ItemHeight;
    }
  }
}
